﻿@model QzgfFrame.System.UserManger.Models.SystemUser
        
@{
    ViewBag.Title = "Register";
}
@using (Html.BeginForm("edit", "User", FormMethod.Post, new { name = "form1", id = "form1" }))
{
    @Html.HiddenFor(m => m.Id)
    @Html.ValidationSummary(true, "Account creation was unsuccessful. Please correct the errors and try again.")
       <div>
        <table cellpadding="0" border="0" cellspacing="0" class="edittable">
            <tbody>
                <tr>
                    <td align="right" class="editcellmessage">用户名:</td>
                    <td align="right" class="editcellverify"><div class="l-verify-star">*</div></td>
                    <td align="left" class="editcell">
                    @if (Model==null||Model.Id == "0")
                    {
                        @Html.TextBoxFor(m => m.Username, new { validate ="{required:true,minlength:1,maxlength:20,remote:'/system/user/isusernameexist?r='+ new Date().getTime(),messages:{required:'请输入用户名',remote:'用户名已经存在!'}}", ltype = "text" })

                    } else
                    {
                        @Html.TextBoxFor(m => m.Username, new { ltype = "text",Readonly="readonly"})
                    } 
                   <!--
                    <input id="Username" ltype="text" name="Username" type="text" validate="{required:true,username:true,minlength:1,maxlength:20,remote:'/system/user/Isusernameexist',messages:{required:'请输入用户名',remote:'用户名已经存在!'}}" value="@ViewData["Username"]" />
                   -->
                </tr>
                <tr>
                    <td align="right" class="editcellmessage">电话:</td>
                    <td align="right" class="editcellverify"><div class="l-verify-star"></div></td>
                    <td align="left" class="editcell">
                    @Html.TextBoxFor(m => m.Tel, new { ltype = "text" })
                    </td> 
                </tr> 
                <tr>
                    <td align="right" class="editcellmessage">电子邮箱:</td>
                    <td align="right" class="editcellverify"><div class="l-verify-star"></div></td>
                    <td align="left" class="editcell">
                    @Html.TextBoxFor(m => m.Email, new { ltype = "text" })
                    </td> 
                </tr>
                <tr>
                    <td align="right" class="editcellmessage">密码</td>
                    <td align="right" class="editcellverify"><div class="l-verify-star">*</div></td>
                    <td align="left" class="editcell">
                     @*Html.TextBoxFor(m => m.Password, new { validate = "{required:true,minlength:1}", ltype = "text" })*@

                     @Html.PasswordFor(m => m.Password, new { validate = "{required:true,minlength:1}", ltype = "text" })
                    </td> 
                </tr>
                <tr>
                    <td align="right" class="editcellmessage">所属部门：</td>
                    <td align="right" class="editcellverify"><div class="l-verify-star">*</div></td>
                    <td align="left" class="editcell">
                     @Html.TextBoxFor(m => m.Departmentname, new { validate = "{required:true,minlength:1}", ltype = "text" })
                     @Html.HiddenFor(m => m.Departmentid)
                    </td>
                </tr>
                <tr>
                    <td align="right" class="editcellmessage">角色：</td>
                    <td align="right" class="editcellverify"><div class="l-verify-star">*</div></td>
                    <td align="left" class="editcell">
                     @Html.TextBoxFor(m => m.Rolenames, new { validate = "{required:true,minlength:1}", ltype = "text" })
                     @Html.HiddenFor(m => m.Roleids)
                    </td>
                </tr>
                <tr>
                    <td align="right" class="editcellmessage">备注：</td>
                    <td align="right" class="editcellverify"><div class="l-verify-star"></div></td>
                    <td align="left" class="editcell">
                    @Html.TextAreaFor(m => m.Remark, new { ltype = "text" })
                    </td>
                </tr>
                <tr>
                <td>

                </td>
                </tr>
            </tbody>
        </table>
    </div> 
}
 
    <script src="@Url.Content("~/Lib/jquery-validation/jquery.validate.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Lib/jquery-validation/messages_cn.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Lib/jquery-validation/jquery.metadata.js")" type="text/javascript"></script>
    <script type="text/javascript">
        //var CurID =  <%=CurID %>;
        var Validator = null;
        $(function () {
            //处理下拉框
            //处理下拉框
            $("#Departmentname").ligerComboBox({
                selectBoxWidth: 200, treeLeafOnly: false,
                selectBoxHeight: 150, valueFieldID: 'Departmentid', textFieldID: 'Departmentname',
                tree: { url: '/system/department/getfather', checkbox: false, topParentIDValue: -1, idFieldName: 'id', parentIDFieldName: 'pid' }
            });
            
            //方案一:将数据转化为json格式传入ViewData中,然后替换&quot;为双引号,eval转化为json
            //var vdata = (' @*Html.ViewData["DropData"]*@').replace(/&quot;/g, "\"");
            //vdata = eval('(' + vdata + ')');
            $("#Rolenames").ligerComboBox({ isShowCheckBox: true, isMultiSelect: true,
                url: '/system/role/getcombobox',
                valueFieldID: 'Roleids'
            });
            
            $.metadata.setType("attr", "validate");
            $("#form1").ligerForm();
            deafultValidate($("#form1"));
            Validator = $("#form1").validate();

        });

        function f_success() {
            $(document).ready(function () {
                $.ligerDialog.confirm("是否继续编辑", "保存成功", function (ok) {
                    $.ligerDialog.closeWaitting();
                    parent.window.frames["mainframe"].f_reload();
                    if (!ok) {
                        parent.window.frames["mainframe"].f_closeWindow();
                    }
                });
            });
        }
        function f_error(message) {
            $(document).ready(function () {
                $.ligerDialog.error(message);
            });
        }
        function f_save() {
            if(!Validator.form()) return;
            $.ligerDialog.waitting("正在保存中...");
            //提交数据
            document.forms[0].submit();
        } 
    </script>
     <style type="text/css">
        .edittable .editcellmessage,.edittable .editcellverify,.edittable .editcell{ padding:4px;line-height:23px;}
        .edittable .editcellmessage{ padding-left:20px;} 
        body { font-size:12px; background:white;}
        /*出现边框效果
        fieldset {
            padding:10px;
            margin:10px;
            color:#333; 
            border:#06c dashed 1px;
        } 
        legend {
            color:#06c;
            font-weight:800; 
            background:#fff;
        }*/

    </style>
